package com.bright.hxj.cwduijie.repository;

import com.bright.hxj.cwduijie.pojo.po.Voucher;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface VoucherRepository extends JpaRepository<Voucher, Integer>, JpaSpecificationExecutor<Voucher> {

    @Query("select ZT_DATA_KEY from Voucher where sjjhbz = :sjjhbz group by ZT_DATA_KEY")
    List<String> getDistinctZtDataKeyBySjjhbz(@Param("sjjhbz") int sjjhbz);

    @Query("select KJQJ from Voucher where ZT_DATA_KEY=:ztDataKey and sjjhbz in (:sjjhbz) group by KJQJ")
    List<String> getDistinctKJQJByZtDataKeyAndSjjhbz(@Param("ztDataKey") String ztDataKey, @Param("sjjhbz") List<Integer> sjjhbz);

    @Query("from Voucher where ZT_DATA_KEY=:ztDataKey and sjjhbz=:sjjhbz and opType=:opType")
    List<Voucher> getByZTDATAKEYAndOpTypeAndSJJHBZ(@Param("ztDataKey") String ztDataKey, @Param("opType") int opType, @Param("sjjhbz") int sjjhbz);

    @Query("from Voucher where ZT_DATA_KEY=:ztDataKey and KJQJ=:KJQJ and sjjhbz in (:sjjhbz) and opType=:opType")
    List<Voucher> getByZTDATAKEYAndKJQJAndOpTypeAndSjjhbz(@Param("ztDataKey") String ztDataKey, @Param("KJQJ") String kjqj, @Param("opType") int opType, @Param("sjjhbz") List<Integer> sjjhbz);
}